//
//  FGResources.m
//  FGChatKit
//
//  Created by Henry on 2021/6/4.
//

#import "FGResources.h"

@implementation FGResources

+ (NSString *)getPathWithMessage:(NSString *)name {
    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
    NSURL *bundleURL = [bundle URLForResource:@"MessageResources" withExtension:@"bundle"];
    NSBundle *resourceBundle = [NSBundle bundleWithURL:bundleURL];
    if (!resourceBundle) {
        NSString *bundlePath = [bundle.resourcePath stringByAppendingPathComponent:@"MessageResources.bundle"];
        resourceBundle = [NSBundle bundleWithPath:bundlePath];
    }
    return [[resourceBundle ?: bundle resourcePath] stringByAppendingPathComponent:name];
}

+ (UIImage *)getImageFromMessage:(NSString *)name {
    NSString *path = [self getPathWithMessage:name];
    return [UIImage imageWithContentsOfFile:path];
}

@end
